package com.ws.shop.schedule;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import com.ws.shop.service.AuctionService;

/**
 * 竞拍任务实例
 * @author Administrator
 *
 */
public class AuctionTask {
	private static Logger log = Logger.getLogger(AuctionTask.class);
	private AuctionService auctionService;

	public AuctionService getAuctionService() {
		return auctionService;
	}

	public void setAuctionService(AuctionService auctionService) {
		this.auctionService = auctionService;
	}

	/**
	 * 修改开始竞拍状态
	 */
	public void startAuction(){
		log.debug("开始：查询已经达到开始时间的还未修改开始状态竞拍记录");
		List<Map<String,Object>> list = auctionService.findAuctionNeedStart();
		int id = 0;
		for(Map<String,Object> map : list){
			id = (Integer)map.get("id");
			log.info("开始更新竞拍ID="+id+"的记录；状态0>>1");
			auctionService.updateState(id,1);
			log.info("已更新竞拍ID="+id+"的记录；状态0>>1");
		}
		log.debug("结束：查询已经达到开始时间的还未修改开始状态竞拍记录");
	}
}
